import {storeBindingsBehavior} from "mobx-miniprogram-bindings"
// 数据源
import {store} from "../store/store"

// custom-tab-bar/index.js
Component({
  behaviors:[storeBindingsBehavior],
  /**
   * 组件的属性列表
   */
  properties: {

  },
  // vant解除样式覆盖，修改样式
  options:{
    styleIsolation:'shared'
  },
  storeBindings:{
    store,
    fields:{
      sum_tabbar:"sum",
      activetabbarindex:"activetabbarindex"
    },
    actions:{
      updateactivetabbarindex:"updateactivetabbarindex"
    }
  },
  // 利用监听全局变化，修改页面的值
  observers:{
    'sum_tabbar':function(sum_tabbar){
      this.setData({
        'list[0].info':sum_tabbar
      })
    },
  },


  /**
   * 组件的初始数据
   */
  data: {
    // icon: {
    //   normal: 'https://img.yzcdn.cn/vant/user-inactive.png',
    //   active: 'https://img.yzcdn.cn/vant/user-active.png',
    // },
    "list": [
      {
        "pagePath": "/pages/day5/day5",
        "text": "day1",
        "iconPath": "../images/tab_home.png",
        "selectedIconPath": "../images/tab_home_select.png",
        "info":0
      },
      {
        "pagePath": "/pages/day2/day2",
        "text": "day2",
        "iconPath": "../images/tab_know.png",
        "selectedIconPath": "../images/tab_know_select.png",
        "info":0
      },
      {
        "pagePath": "/pages/day3_1/day3_1",
        "text": "day3_1",
        "iconPath": "../images/tab_know.png",
        "selectedIconPath": "../images/tab_know_select.png",
        "info":0
      }
    ]
  },
  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
      // event.detail 的值为当前选中项的索引
      // this.setData({ active: event.detail });
      // console.log(event.detail)
      wx.switchTab({
        url: this.data.list[event.detail].pagePath,
      })
      this.updateactivetabbarindex(event.detail) 
    },
  }
})
